﻿<UserControl x:Class="OSChina.Controls.TweetListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">
    <UserControl.Resources>
        <DataTemplate x:Key="template_Normal">
            <Grid Margin="0,20,0,26">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="346" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <!-- 头像 -->
                <Image Name="img" Width="50" Height="50"  Margin="8,6,14,0"  Source="{Binding portrait,Mode=OneTime}" VerticalAlignment="Top" MouseLeftButtonUp="img_MouseLeftButtonDown" />
                <Grid Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Text="{Binding authorFormat, Mode=OneTime}" HorizontalAlignment="Left" FontSize="23"  Foreground="{StaticResource PhoneAccentBrush}" />
                    
                    <TextBlock Text="{Binding body, Mode=OneTime}" FontSize="23" TextWrapping="Wrap" Grid.Row="1" />

                    <Image Name="imgTweet" Loaded="imgTweet_Loaded" Source="{Binding imgSmall, Mode=OneTime}" Visibility="{Binding imgSmallVisible, Mode=OneTime}" HorizontalAlignment="Left" Margin="0,12,0,2" Grid.Row="2" MaxHeight="240" MaxWidth="240" Stretch="None"  MouseLeftButtonUp="imgTweet_MouseLeftButtonDown" />
                    
                    <TextBlock Text="{Binding pubDateFormat, Mode=OneTime}" Grid.Row="3" Foreground="Gray" Margin="0,10,0,0" FontSize="19" />
                </Grid>
                <Grid Width="38" Height="21" Margin="10,9,0,0" Background="{StaticResource PhoneAccentBrush}" Grid.Column="2" VerticalAlignment="Top">
                    <TextBlock Text="{Binding commentCount,Mode=OneTime}" FontSize="17" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Grid>
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem x:Name="menu_Delete"
                                                  Header="删除动弹" Click="menu_Delete_Click" />
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <ListBox Name="list_Tweets" ItemTemplate="{StaticResource template_Normal}" Height="650"  VerticalAlignment="Top" SelectionChanged="list_Tweets_SelectionChanged">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel CacheMode="BitmapCache"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
    </Grid>
</UserControl>
